from dotenv import load_dotenv
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_deepseek import ChatDeepSeek

load_dotenv(verbose=True)

prompt_template = ChatPromptTemplate.from_messages([
    ("system", "你是一个生活助手"),
    ("user", "给我讲一个关于{topic}的笑话")
])

llm = ChatDeepSeek(
    model="deepseek-chat",
    temperature=0.5
)

parser = StrOutputParser()

chain = prompt_template | llm | parser

result = chain.invoke({"topic": "猫"})
print(result)